﻿using DevExpress.XtraEditors;
using DevExpress.XtraGrid.Views.Grid;
using DevExpress.XtraGrid.Views.Grid.ViewInfo;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.IO;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;

namespace ProjectModule
{
    public partial class FormProjectSelect : DevExpress.XtraEditors.XtraForm
    {
        public string strProjectName
        {
            get;
            set;
        }
        public FormProjectSelect()
        {
            InitializeComponent();
        }

        private void FormProjectSelect_Load(object sender, EventArgs e)
        {
            DirectoryInfo dirInfoParent = new DirectoryInfo(Application.StartupPath + @"/ProjectSetting/");
            DirectoryInfo[] dirInfos = dirInfoParent.GetDirectories();
            List<ProjectItem> listProjectNames = new List<ProjectItem>();
            foreach (DirectoryInfo dirInfo in dirInfos)
            {
                listProjectNames.Add(new ProjectItem(dirInfo.Name));
            }
            gridControl1.DataSource = listProjectNames;
        }

       

       

        private void gridControl1_DoubleClick(object sender, EventArgs e)
        {
            GridView gridView = gridControl1.FocusedView as GridView;
            if (gridView != null)
            {
                int iIndex = gridView.GetFocusedDataSourceRowIndex();
                if (iIndex> -1)
                {
                    strProjectName = gridView.GetFocusedRowCellDisplayText("ProjectName");
                    if (strProjectName == ProjectManager.ProjectSetting.ProjectName)
                    {
                        DialogResult = DialogResult.No;

                    }
                    else
                    {
                        DialogResult = DialogResult.OK;

                    }
                }
                else
                {
                    MessageBox.Show("没有选择项目");
                }

            }
            else
            {
                MessageBox.Show("没有选择项目");
            }

        }
        
    }
}